// 连接MySql
const mysql = require('mysql2')

const connections = mysql.createPool({
  host: 'localhost',
  port: 3306,
  database: 'igame',
  user: 'root',
  password: 'qaz111104'
})

connections.getConnection((err, conn) => {
  conn.connect((err) => {
    if (err) {
      console.log('链接失败');
    } else {
      console.log('链接成功');
    }
  })
})

// 调用promise方法，返回一个promise对象
module.exports = connections.promise()